import React from "react";
import {List, Table, Row, Col, Tag} from 'antd';
import IconFont3 from "../../util/autoIcon/activity";
import IconFont5 from "../../util/autoIcon/activity_newly";
import './Activity.css'
import {Link} from "react-router-dom";
import API from "../../api/api";


export default class Activity extends React.Component{
    data = []

    isNotify = (record)=>{
        let currentDate = new Date()
        let date = new Date(record.updateTime);
        if(record.new!="" && record.new!=null){
            date.setDate(date.getDate()+Number.parseInt(record.new));
            if(currentDate<=date){
                return <img src="/new_red_1.png" style={{width:"100%"}}/>
                // return <IconFont5 id="icon5" style={{height:"100%",float:"right"}} type="icon-new" />
            }
        }
    }

    render() {
        this.data=API.previewActivityList()
        return (
            <List
                className="activity-list"
                size="small"
                header={
                    <Link to="/eip/table/activity">
                        <span className="folder-ellipsis" style={{color:"black",fontSize:"1rem",fontWeight:"bold"}}><IconFont3 type={"icon-hdgl"} /> 最新活动</span>
                    </Link>
                }
                footer={<Link to="/eip/table/activity">查看更多</Link>}
                bordered
                dataSource={this.data}
                renderItem={item => (
                    <List.Item >
                        <Row gutter={10} >
                            <Col className="width-image-setting" style={{width:"30%"}}>
                                <img src={item.figure} />
                            </Col>
                            <Col style={{paddingLeft:"1.5rem",width:"34%",verticalAlign:"middle"}} >
                                <Link to={`/eip/file/activity/${item.key}`}>
                                    <span style={{float:"left"}}>{item.name}</span>
                                </Link>
                            </Col>
                            <Col style={{width:"8%"}} >
                                {this.isNotify(item)}
                            </Col>
                            <Col style={{width:"28%"}}>
                                <span className="folder-ellipsis" title={item.updateTime}>{item.updateTime}</span>
                            </Col>
                        </Row>
                    </List.Item>
                )}
            />
        );
    }
}


